using Fishing.Abstractions;
using Fishing.Model;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;

namespace Fishing.Core
{
    public static class MonitorHelper
    {
        private static readonly List<IMonitor> _monitors = new();

        public static void Initialize()
        {
            MonitorManager.Initialize();
            UpdateMonitorList();
        }

        public static bool IsMultiMonitor()
        {
            return MonitorManager.Instance.Monitors.Count > 1;
        }

        public static IMonitor GetSecondaryMonitor()
        {
            return new PoseidonMonitor(MonitorManager.Instance.SecondaryMonitor);
        }

        private static void UpdateMonitorList()
        {
            _monitors.Clear();

            MonitorManager.Instance.Monitors.ToList().ForEach(
                screen => _monitors.Add(new PoseidonMonitor(screen)));
        }

        public static Rectangle RectToRectangle(System.Windows.Rect rect)
        {
            return new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
        }
    }
}